import java.util.Scanner;

public class factor {
    //获取两个数的最大公因数
    private static int fun_greatest_common_factor(int first,int second){
        //记录最大公因数
        int factor = 1;
        for (int i=1;i<=first;i++){
           if(first%i==0&&second%i==0){
               factor=i;
           }
        }
        return factor;
    }

    public static void main(String arg[]){
        Scanner user_input_scanner = new Scanner(System.in);
        System.out.println("请输入第一个正整数:");
        int first_num = user_input_scanner.nextInt() ;
        System.out.println("请输入第二个正整数:");
        int second_num = user_input_scanner.nextInt() ;
        System.out.println("最大公因数是："+fun_greatest_common_factor(first_num,second_num));
    }
}
